function isInt(str){
    var patt=/^\d+$/;
    return patt.test(str);
}
function isEmail(str){
    var patt=/^\w+([.]\w+)?@\w+[.]\w+([.]\w+)?$/;
    return patt.test(str);
}
function isFloat(str){
    var patt=/^\d+([.]\d+)?$/;
    return patt.test(str);
}
function isDate(str){
    var patt=/\d{1,2}\/\d{1,2}\/\d{4}/;
    return patt.test(str);
}
/**
 *validate to make sure that an array of checkboxes or radios has at least 1  item is selected
 **/
function isSelected(name){    
    var list=document.getElementsByName(name);	 
	var len=list.length;
    for(var i=0;i<len;i++){
        if(list[i].checked){
            return true;
        }      
    }
    return false;
}
function validate(array){
    var len=array.length;
    var test=true;
    var cur=true;
    
    for(var i=0;i<len;i++){
        var name=array[i].name;
        var type=array[i].type;        
        if(type=='integer'){
            cur=isInt(document.getElementById(name).value);            
        }else if(type=='float'){
            cur=isFloat(document.getElementById(name).value);
        }else if(type=='email'){
            cur=isEmail(document.getElementById(name).value);
        }else if(type=='date'){
            cur=isDate(document.getElementById(name).value);
        }else if(type=='array'){
            cur=isSelected(name);
        }     
        test=(test && cur);
        if(!cur && type!='array'){         
            document.getElementById(name).setAttribute("style", "color:red");
            //.prepend("<span style='color:red;'>*</span>");		
        }		
    }  	
    return test;

}